package com.example.data.factory.web1.controller;

import com.example.data.factory.common.Dto.*;
import com.example.data.factory.common.result.R;
import com.example.data.factory.entity.entity.DataStandard;
import com.example.data.factory.service.service.DataStandardService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 数据标准目录 前端控制器
 * </p>
 *
 * @author lhy
 * @since 2025-03-03
 */
@RestController
@RequestMapping("/dataStandard")
public class DataStandardController {
    @Resource
    private  DataStandardService dataStandardService;

    @GetMapping("/SearchDataStandard")
    public R<DataStandard> SearchDataStandard(@ModelAttribute SearchDtaStandardDto searchDtaStandardDto) {
        return dataStandardService.search ( searchDtaStandardDto );
    }

    @PostMapping("/InsertDataStandard")
    public R<DataStandard> InsertDataStandard(@RequestBody @Validated InsertDataStandardDto insertDataStandardDto) {
        return dataStandardService.insert ( insertDataStandardDto );
    }

    @PutMapping("/UpdateDataStandard")
    public R<DataStandard> UpdateDataStandard(@RequestBody @Validated UpdateDataStandard updateDataStandard) {
        return dataStandardService.updates ( updateDataStandard );
    }
    @PutMapping("/UpdateDataStandardStatus")
    public R<DataStandard> UpdateDataStandardStatus (@RequestBody UpdateDataStandardStatusDto updateDataStandardStatusDto) {
        return dataStandardService.updatestatus(updateDataStandardStatusDto);
    }
    @DeleteMapping("/DeleteDataStandard")
    public R<DataStandard> DeleteDataStandard (@RequestBody DeleteDataStandardDto deleteDataStandardDto) {
        return dataStandardService.delete(deleteDataStandardDto);
    }
    @GetMapping("SearchDataStandardDetailByCode")
    public R<DataStandard> SearchDataStandardDetailByCode (@ModelAttribute DeleteDataStandardDto deleteDataStandardDto1) {
        return dataStandardService.searchdetail (deleteDataStandardDto1);
    }
    @GetMapping("/SearchDetailByDictName")
    public R<Map<String, Object>> SearchDetailByDictName (@ModelAttribute SearchByDictNameDto searchByDictNameDto) {
        return dataStandardService.searchbydetail ( searchByDictNameDto );

    }
    @PutMapping("/UpdateDataStandaedStatusBatch")
    public R<DataStandard> UpdateDataStandaedStatusBatch (@RequestBody List<UpdateDataStandardStatusDto> updateDataStandardStatusDtos) {
        return dataStandardService.updateStatusBatch(updateDataStandardStatusDtos);
    }

}
